package com.surfilter.risk.controller;

import com.surfilter.risk.service.BusinessService;
import com.surfilter.risk.service.PunishService;
import com.surfilter.risk.service.RiskListGeneralService;
import com.surfilter.risk.service.SearchService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

/**
 * RiskController
 * Dis:企业风险库查询接口
 * Created by grom on 2017/5/2.
 */
@Controller
@RequestMapping("/risk")
public class RiskController {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
    //若干service
    @Autowired
    private PunishService punishService;
    @Autowired
    private RiskListGeneralService riskListGeneralService;
    @Autowired
    private SearchService searchService;
    @Autowired
    private BusinessService businessService;

//    method = RequestMethod.GET  接口调试方便删除 结束后添加  TODO

    /**
     * 首页数据接口
     *
     * @return
     */
    @RequestMapping(value = "/index",
            produces = {"application/json;charset=UTF-8"})
    @ResponseBody
    public String index() {
        return punishService.getIndexMSG();
    }

    /**
     * 全国企业处罚top接口
     *
     * @return
     */
    @RequestMapping(value = "/punishTop",
            produces = {"application/json;charset=UTF-8"})
    @ResponseBody
    public String punishTop(String type, String time) {
        return punishService.getPunishTopMSG(type, time);
    }

    /**
     * 搜索接口
     *
     * @return
     */
    @RequestMapping(value = "/search",
            produces = {"application/json;charset=UTF-8"})
    @ResponseBody
    public String search(String stitle, Integer pageNo,
                         Integer pageSize, String scope,
                         String trade, String position,
                         String compstate, String type) {
        return searchService.search(stitle, pageNo, pageSize, scope,
                trade, position, compstate, type);
    }

    /**
     * 全国惩戒数量分布接口
     *
     * @return
     */
    @RequestMapping(value = "/punishDistribution",
            produces = {"application/json;charset=UTF-8"})
    @ResponseBody
    public String punishDistribution() {
        return punishService.punishDistribution();
    }

    /**
     * 全国惩戒实时数据更新接口
     *
     * @return
     */
    @RequestMapping(value = "/punishDataFeed",
            produces = {"application/json;charset=UTF-8"})
    @ResponseBody
    public Map<String, Object> punishDataFeed() {
        return punishService.punishDataFeed();
    }

    /**
     * 企业详情接口
     *
     * @return
     */
    @RequestMapping(value = "/businessDetails",
            produces = {"application/json;charset=UTF-8"})
    @ResponseBody
    public Map<String, Object> businessDetails(Integer id) {
        return businessService.businessDetails(id);
    }

    /**
     * 处罚列表接口
     *
     * @return
     */
    @RequestMapping(value = "/punishList",
            produces = {"application/json;charset=UTF-8"})
    @ResponseBody
    public Map<String, Object> punishList(String id, Integer pageNo, Integer pageSize, String type) {
        return punishService.punishList(id, pageNo, pageSize, type);
    }

    /**
     * 处罚详情接口
     *
     * @return
     */
    @RequestMapping(value = "/punishDetails",
            produces = {"application/json;charset=UTF-8"})
    @ResponseBody
    public Map<String, Object> punishDetails(String id, String type) {
        return punishService.punishDetails(id, type);
    }

    /**
     * 企业舆情接口
     *
     * @return
     */
    @RequestMapping(value = "/businessPublicOption",
            produces = {"application/json;charset=UTF-8"})
    @ResponseBody
    public String businessPublicOption() {
        return punishService.businessPublicOption();
    }


    /**
     * 企业风险聚焦接口
     *
     * @return
     */
    @RequestMapping(value = "/businessRiskMatters",
            produces = {"application/json;charset=UTF-8"})
    @ResponseBody
    public String businessRiskMatters(Integer pageNo, Integer pageSize, String type) {
        return punishService.businessRiskMatters(pageNo, pageSize, type);
    }

    /**
     * 本周热点事件接口
     *
     * @return
     */
    @RequestMapping(value = "/hotIssueThisWeek",
            produces = {"application/json;charset=UTF-8"})
    @ResponseBody
    public String hotIssueThisWeek() {
        return punishService.hotIssueThisWeek();
    }

    /**
     * 企业负面舆情排行榜接口
     *
     * @return
     */
    @RequestMapping(value = "/negativePublicOptionList",
            produces = {"application/json;charset=UTF-8"})
    @ResponseBody
    public String negativePublicOptionList() {
        return punishService.negativePublicOptionList();
    }

    /**
     * 企业风险聚焦详情接口
     *
     * @return
     */
    @RequestMapping(value = "/businessRiskMattersDetails",
            produces = {"application/json;charset=UTF-8"})
    @ResponseBody
    public String businessRiskMattersDetails(Integer id) {
        return punishService.businessRiskMattersDetails(id);
    }

    /**
     * 企业风险榜单-总体概况接口
     *
     * @return
     */
    @RequestMapping(value = "/businessRiskListGeneral",
            produces = {"application/json;charset=UTF-8"})
    @ResponseBody
    public String businessRiskListGeneral() {
        return riskListGeneralService.businessRiskListGeneral();
    }

    /**
     * 企业风险榜单-地区、行业、行政 top10接口
     *
     * @return
     */
    @RequestMapping(value = "/businessRiskListTopTen",
            produces = {"application/json;charset=UTF-8"})
    @ResponseBody
    public String businessRiskListTopTen(String spage, String type, String year, String month) {
        return riskListGeneralService.businessRiskListTopTen(spage, type, year, month);
    }

    /**
     * 企业风险榜单-各地区、行业、行政 处罚菜单接口
     *
     * @return
     */
    @RequestMapping(value = "/businessRiskListMenu",
            produces = {"application/json;charset=UTF-8"})
    @ResponseBody
    public String businessRiskListMenu(String spage) {
        return riskListGeneralService.businessRiskListMenu(spage);
    }

    /**
     * 企业风险榜单-各地区、行业、行政 处罚列表接口
     * 查询页面	spage
     * 处罚菜单主键	id
     * 企业名称	company
     * 年	year
     * 月	month
     * 查询第几页数	pageNo
     * 每页显示记录数	pageSize
     *
     * @return
     */
    @RequestMapping(value = "/businessRiskListView",
            produces = {"application/json;charset=UTF-8"})
    @ResponseBody
    public String businessRiskListView(String spage, Integer id, String company,
                                       String year, String month,
                                       Integer pageNo, Integer pageSize) {
        return riskListGeneralService.businessRiskListView(spage, id, company, year, month, pageNo, pageSize);
    }
}
